namespace = xit_infection

planet_event = {
	id = xit_infection.1
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		any_owned_pop_group = {
			species = { has_trait = trait_xenomorph }
		}
	}

	immediate = {
		add_modifier = { modifier = xit_xenomorph_infestation days = 720 }

		if = {
			limit = {
				any_owned_pop_group = {
					pop_group_size >= 100
					species = {
						is_robotic = no
						NOT = { has_trait = trait_mechanical }
						NOT = { has_trait = trait_xenomorph }
					}
				}
			}

			# Baseline exposure. Biosecurity tech and containment labs slow the spread.
			if = {
				limit = { owner = { has_ascension_perk = ap_xit_extragalactic_biosecurity_mandate } }
				if = {
					limit = { owner = { xit_biosecurity_science_tier_3 = yes } }
					random_list = {
						1 = { xit_convert_one_pop = yes }
						299 = {
						}
					}
				}
				else_if = {
					limit = { owner = { xit_biosecurity_science_tier_2 = yes } }
					random_list = {
						1 = { xit_convert_one_pop = yes }
						149 = {
						}
					}
				}
				else_if = {
					limit = { owner = { xit_biosecurity_science_tier_1 = yes } }
					random_list = {
						1 = { xit_convert_one_pop = yes }
						99 = {
						}
					}
				}
				else = {
					random_list = {
						2 = { xit_convert_one_pop = yes }
						98 = {
						}
					}
				}
			}
			else_if = {
				limit = {
					has_modifier = xit_ovomorph_quarantine_zone
					owner = { OR = { has_tradition = tr_xit_biosecurity_quarantine_protocols has_tradition = tr_xit_containment_quarantine_protocols } }
				}
				random_list = {
					1 = { xit_convert_one_pop = yes }
					99 = {
					}
				}
			}
			else_if = {
				limit = {
					has_building = building_xit_xenomorph_containment_lab
					owner = { OR = { has_tradition = tr_xit_biosecurity_containment_labs has_tradition = tr_xit_containment_research_labs } }
				}
				random_list = {
					2 = { xit_convert_one_pop = yes }
					98 = {
					}
				}
			}
			else_if = {
				limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish } } }
				random_list = {
					5 = { xit_convert_one_pop = yes }
					95 = {
					}
				}
			}
			else_if = {
				limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_adopt has_tradition = tr_xit_containment_command_adopt } } }
				random_list = {
					12 = { xit_convert_one_pop = yes }
					88 = {
					}
				}
			}
			else_if = {
				limit = { has_building = building_xit_xenomorph_containment_lab }
				random_list = {
					8 = { xit_convert_one_pop = yes }
					92 = {
					}
				}
			}
			else_if = {
				limit = { owner = { has_technology = tech_xit_xenomorph_biosecurity } }
				random_list = {
					18 = { xit_convert_one_pop = yes }
					82 = {
					}
				}
			}
			else = {
				random_list = {
					30 = { xit_convert_one_pop = yes }
					70 = {
					}
				}
			}

			# Perfect Host Cycle pressure: seeded worlds experience additional lifecycle pressure.
			if = {
				limit = { has_carrier_flag = xit_perfect_host_cycle_conversion_pressure }
				if = {
					limit = {
						OR = {
							has_modifier = xit_xenomorph_outbreak
							pop_amount_percentage = {
								percentage >= 0.20
								limit = { species = { has_trait = trait_xenomorph } }
							}
							count_owned_pop_amount = {
								count >= 2000
								limit = { species = { has_trait = trait_xenomorph } }
							}
						}
					}
					if = {
						limit = { owner = { has_ascension_perk = ap_xit_extragalactic_biosecurity_mandate } }
						if = {
							limit = { owner = { xit_biosecurity_science_tier_3 = yes } }
							random_list = {
								4 = { xit_convert_one_pop = yes }
								96 = {
								}
							}
						}
						else_if = {
							limit = { owner = { xit_biosecurity_science_tier_2 = yes } }
							random_list = {
								8 = { xit_convert_one_pop = yes }
								92 = {
								}
							}
						}
						else_if = {
							limit = { owner = { xit_biosecurity_science_tier_1 = yes } }
							random_list = {
								12 = { xit_convert_one_pop = yes }
								88 = {
								}
							}
						}
						else = {
							random_list = {
								16 = { xit_convert_one_pop = yes }
								84 = {
								}
							}
						}
					}
					else = {
						random_list = {
							20 = { xit_convert_one_pop = yes }
							80 = {
							}
						}
					}
				}
				else = {
					if = {
						limit = { owner = { has_ascension_perk = ap_xit_extragalactic_biosecurity_mandate } }
						if = {
							limit = { owner = { xit_biosecurity_science_tier_3 = yes } }
							random_list = {
								2 = { xit_convert_one_pop = yes }
								98 = {
								}
							}
						}
						else_if = {
							limit = { owner = { xit_biosecurity_science_tier_2 = yes } }
							random_list = {
								4 = { xit_convert_one_pop = yes }
								96 = {
								}
							}
						}
						else_if = {
							limit = { owner = { xit_biosecurity_science_tier_1 = yes } }
							random_list = {
								6 = { xit_convert_one_pop = yes }
								94 = {
								}
							}
						}
						else = {
							random_list = {
								8 = { xit_convert_one_pop = yes }
								92 = {
								}
							}
						}
					}
					else = {
						random_list = {
							10 = { xit_convert_one_pop = yes }
							90 = {
							}
						}
					}
				}
			}

			# Large brood pressure: absolute Xenomorph count matters even on huge planets.
			if = {
				limit = {
					OR = {
						pop_amount_percentage = {
							percentage >= 0.10
							limit = { species = { has_trait = trait_xenomorph } }
						}
						count_owned_pop_amount = {
							count >= 1000
							limit = { species = { has_trait = trait_xenomorph } }
						}
					}
				}
				if = {
					limit = { owner = { has_ascension_perk = ap_xit_extragalactic_biosecurity_mandate } }
					if = {
						limit = { owner = { xit_biosecurity_science_tier_3 = yes } }
						random_list = {
							1 = { xit_convert_one_pop = yes }
							99 = {
							}
						}
					}
					else_if = {
						limit = { owner = { xit_biosecurity_science_tier_2 = yes } }
						random_list = {
							2 = { xit_convert_one_pop = yes }
							98 = {
							}
						}
					}
					else_if = {
						limit = { owner = { xit_biosecurity_science_tier_1 = yes } }
						random_list = {
							3 = { xit_convert_one_pop = yes }
							97 = {
							}
						}
					}
					else = {
						random_list = {
							5 = { xit_convert_one_pop = yes }
							95 = {
							}
						}
					}
				}
				else_if = {
					limit = {
						has_building = building_xit_xenomorph_containment_lab
						owner = { OR = { has_tradition = tr_xit_biosecurity_containment_labs has_tradition = tr_xit_containment_research_labs } }
					}
					random_list = {
						5 = { xit_convert_one_pop = yes }
						95 = {
						}
					}
				}
				else_if = {
					limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish } } }
					random_list = {
						10 = { xit_convert_one_pop = yes }
						90 = {
						}
					}
				}
				else_if = {
					limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_adopt has_tradition = tr_xit_containment_command_adopt } } }
					random_list = {
						30 = { xit_convert_one_pop = yes }
						70 = {
						}
					}
				}
				else_if = {
					limit = { has_building = building_xit_xenomorph_containment_lab }
					random_list = {
						25 = { xit_convert_one_pop = yes }
						75 = {
						}
					}
				}
				else_if = {
					limit = { owner = { has_technology = tech_xit_xenomorph_biosecurity } }
					random_list = {
						40 = { xit_convert_one_pop = yes }
						60 = {
						}
					}
				}
				else = {
					random_list = {
						65 = { xit_convert_one_pop = yes }
						35 = {
						}
					}
				}
			}

			# Source-tech pressure: Xenomorph empires with advanced infection research add extra yearly conversion rolls on seeded worlds.
			if = {
				limit = { has_carrier_flag = xit_brood_host_selection_pressure }
				if = {
					limit = { owner = { has_ascension_perk = ap_xit_extragalactic_biosecurity_mandate } }
					if = {
						limit = { owner = { xit_biosecurity_science_tier_3 = yes } }
						random_list = {
							2 = { xit_convert_one_pop = yes }
							98 = {
							}
						}
					}
					else_if = {
						limit = { owner = { xit_biosecurity_science_tier_2 = yes } }
						random_list = {
							4 = { xit_convert_one_pop = yes }
							96 = {
							}
						}
					}
					else_if = {
						limit = { owner = { xit_biosecurity_science_tier_1 = yes } }
						random_list = {
							6 = { xit_convert_one_pop = yes }
							94 = {
							}
						}
					}
					else = {
						random_list = {
							8 = { xit_convert_one_pop = yes }
							92 = {
							}
						}
					}
				}
				else = {
					random_list = {
						10 = { xit_convert_one_pop = yes }
						90 = {
						}
					}
				}
			}
			if = {
				limit = { has_carrier_flag = xit_biocontainment_subversion_pressure }
				if = {
					limit = {
						OR = {
							has_modifier = xit_ovomorph_quarantine_zone
							has_building = building_xit_xenomorph_containment_lab
							owner = { has_technology = tech_xit_xenomorph_biosecurity }
							owner = { OR = { has_tradition = tr_xit_biosecurity_adopt has_tradition = tr_xit_containment_command_adopt } }
						}
					}
					random_list = {
						12 = { xit_convert_one_pop = yes }
						88 = {
						}
					}
				}
				else = {
					random_list = {
						6 = { xit_convert_one_pop = yes }
						94 = {
						}
					}
				}
			}
			if = {
				limit = { has_carrier_flag = xit_macro_ovomorph_seeding_pressure }
				if = {
					limit = {
						OR = {
							has_modifier = xit_xenomorph_outbreak
							pop_amount_percentage = {
								percentage >= 0.20
								limit = { species = { has_trait = trait_xenomorph } }
							}
							count_owned_pop_amount = {
								count >= 2000
								limit = { species = { has_trait = trait_xenomorph } }
							}
						}
					}
					random_list = {
						25 = { xit_convert_one_pop = yes }
						75 = {
						}
					}
				}
				else = {
					random_list = {
						15 = { xit_convert_one_pop = yes }
						85 = {
						}
					}
				}
			}
			if = {
				limit = {
					any_owned_pop_group = {
						species = { has_trait = trait_xenomorph_brood_parasitism }
					}
				}
				random_list = {
					15 = { xit_convert_one_pop = yes }
					85 = {
					}
				}
			}
			if = {
				limit = {
					any_owned_pop_group = {
						species = { has_trait = trait_xenomorph_brood_parasitism }
					}
				}
				random_list = {
					10 = { xit_convert_one_pop = yes }
					90 = {
					}
				}
			}
			if = {
				limit = {
					OR = {
						has_carrier_flag = xit_ovomorph_bearer_pressure
						has_carrier_flag = xit_stalker_caste_pressure
					}
				}
				random_list = {
					10 = { xit_convert_one_pop = yes }
					90 = {
					}
				}
			}
			if = {
				limit = {
					OR = {
						pop_amount_percentage = {
							percentage >= 0.20
							limit = { species = { has_trait = trait_xenomorph } }
						}
						count_owned_pop_amount = {
							count >= 2000
							limit = { species = { has_trait = trait_xenomorph } }
						}
					}
				}
				if = {
					limit = { owner = { has_ascension_perk = ap_xit_extragalactic_biosecurity_mandate } }
					if = {
						limit = { owner = { xit_biosecurity_science_tier_3 = yes } }
						random_list = {
							2 = { xit_convert_one_pop = yes }
							98 = {
							}
						}
					}
					else_if = {
						limit = { owner = { xit_biosecurity_science_tier_2 = yes } }
						random_list = {
							4 = { xit_convert_one_pop = yes }
							96 = {
							}
						}
					}
					else_if = {
						limit = { owner = { xit_biosecurity_science_tier_1 = yes } }
						random_list = {
							6 = { xit_convert_one_pop = yes }
							94 = {
							}
						}
					}
					else = {
						random_list = {
							10 = { xit_convert_one_pop = yes }
							90 = {
							}
						}
					}
				}
				else_if = {
					limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish } } }
					random_list = {
						20 = { xit_convert_one_pop = yes }
						80 = {
						}
					}
				}
				else_if = {
					limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_adopt has_tradition = tr_xit_containment_command_adopt } } }
					random_list = {
						50 = { xit_convert_one_pop = yes }
						50 = {
						}
					}
				}
				else = {
					xit_convert_one_pop = yes
				}
			}
			if = {
				limit = {
					OR = {
						pop_amount_percentage = {
							percentage >= 0.50
							limit = { species = { has_trait = trait_xenomorph } }
						}
						count_owned_pop_amount = {
							count >= 5000
							limit = { species = { has_trait = trait_xenomorph } }
						}
					}
				}
				if = {
					limit = { owner = { has_ascension_perk = ap_xit_extragalactic_biosecurity_mandate } }
					if = {
						limit = { owner = { xit_biosecurity_science_tier_3 = yes } }
						random_list = {
							20 = { xit_convert_one_pop = yes }
							80 = {
							}
						}
					}
					else_if = {
						limit = { owner = { xit_biosecurity_science_tier_2 = yes } }
						random_list = {
							35 = { xit_convert_one_pop = yes }
							65 = {
							}
						}
					}
					else_if = {
						limit = { owner = { xit_biosecurity_science_tier_1 = yes } }
						random_list = {
							50 = { xit_convert_one_pop = yes }
							50 = {
							}
						}
					}
					else = {
						random_list = {
							70 = { xit_convert_one_pop = yes }
							30 = {
							}
						}
					}
				}
				else_if = {
					limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish } } }
					xit_convert_one_pop = yes
				}
				else_if = {
					limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_adopt has_tradition = tr_xit_containment_command_adopt } } }
					xit_convert_one_pop = yes
				}
				else = {
					xit_convert_one_pop = yes
					xit_convert_one_pop = yes
				}
			}
			if = {
				limit = {
					OR = {
						pop_amount_percentage = {
							percentage >= 0.80
							limit = { species = { has_trait = trait_xenomorph } }
						}
						count_owned_pop_amount = {
							count >= 8000
							limit = { species = { has_trait = trait_xenomorph } }
						}
					}
				}
				if = {
					limit = { owner = { has_ascension_perk = ap_xit_extragalactic_biosecurity_mandate } }
					if = {
						limit = { owner = { xit_biosecurity_science_tier_3 = yes } }
						random_list = {
							50 = { xit_convert_one_pop = yes }
							50 = {
							}
						}
					}
					else_if = {
						limit = { owner = { xit_biosecurity_science_tier_2 = yes } }
						random_list = {
							75 = { xit_convert_one_pop = yes }
							25 = {
							}
						}
					}
					else = {
						xit_convert_one_pop = yes
					}
				}
				else_if = {
					limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish } } }
					xit_convert_one_pop = yes
				}
				else_if = {
					limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_adopt has_tradition = tr_xit_containment_command_adopt } } }
					xit_convert_one_pop = yes
					xit_convert_one_pop = yes
				}
				else = {
					xit_convert_one_pop = yes
					xit_convert_one_pop = yes
					xit_convert_one_pop = yes
				}
			}
		}
		xit_clean_one_remnant_pop = yes
			if = {
				limit = {
					is_colony = yes
					exists = owner
					owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
					NOT = { has_carrier_flag = xit_xenomorph_outbreak_started }
					pop_amount_percentage = {
					percentage >= 0.20
					limit = {
						species = { has_trait = trait_xenomorph }
					}
				}
			}
			planet_event = { id = xit_infection.2 }
		}
			if = {
				limit = {
					is_colony = yes
					exists = owner
					owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
					NOT = { has_carrier_flag = xit_xenomorph_colony_overrun }
					pop_amount_percentage = {
					percentage >= 0.80
					limit = {
						species = { has_trait = trait_xenomorph }
					}
				}
			}
			planet_event = { id = xit_infection.3 }
		}
	}
}

planet_event = {
	id = xit_infection.2
	title = xit_infection.2.name
	desc = xit_infection.2.desc
	picture = GFX_xit_event_xenomorph_containment_breach
	location = ROOT

	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		NOT = { has_carrier_flag = xit_xenomorph_outbreak_started }
		any_owned_pop_group = {
			species = { has_trait = trait_xenomorph }
		}
		pop_amount_percentage = {
			percentage >= 0.20
			limit = {
				species = { has_trait = trait_xenomorph }
			}
		}
	}

	immediate = {
		set_carrier_flag = xit_xenomorph_outbreak_started
		remove_modifier = xit_xenomorph_infestation
		add_modifier = { modifier = xit_xenomorph_outbreak days = 3600 }
		add_planet_devastation = 15
	}

	option = {
		name = xit_infection.2.a
	}
}

planet_event = {
	id = xit_infection.3
	title = xit_infection.3.name
	desc = xit_infection.3.desc
	picture = GFX_xit_event_colony_overrun
	location = ROOT

	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		NOT = { has_carrier_flag = xit_xenomorph_colony_overrun }
		any_owned_pop_group = {
			species = { has_trait = trait_xenomorph }
		}
		pop_amount_percentage = {
			percentage >= 0.80
			limit = {
				species = { has_trait = trait_xenomorph }
			}
		}
	}

	immediate = {
		set_carrier_flag = xit_xenomorph_colony_overrun
		remove_modifier = xit_xenomorph_infestation
		remove_modifier = xit_xenomorph_outbreak
		add_modifier = { modifier = xit_xenomorph_overrun days = -1 }
		add_planet_devastation = 50
	}

	option = {
		name = xit_infection.3.a
	}
}

planet_event = {
	id = xit_infection.4
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		has_carrier_flag = xit_xenomorph_outbreak_started
		NOT = { has_carrier_flag = xit_xenomorph_colony_overrun }
		any_owned_pop_group = {
			species = { has_trait = trait_xenomorph }
		}
		pop_amount_percentage = {
			percentage >= 0.20
			limit = {
				species = { has_trait = trait_xenomorph }
			}
		}
	}

	immediate = {
		random_list = {
			35 = {
				add_planet_devastation = 10
				add_modifier = { modifier = xit_xenomorph_outbreak days = 1800 }
			}
			65 = {
			}
		}
	}
}

planet_event = {
	id = xit_infection.6
	title = xit_infection.6.name
	desc = xit_infection.6.desc
	picture = GFX_xit_event_terminal_xenomorph_collapse
	location = ROOT

	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		has_carrier_flag = xit_xenomorph_terminal_warning
		has_carrier_flag = xit_xenomorph_terminal_warning_mature
		NOT = { has_carrier_flag = xit_xenomorph_terminal_collapse_started }
		any_owned_pop_group = {
			species = { has_trait = trait_xenomorph }
		}
		OR = {
			pop_amount_percentage = {
				percentage >= 0.50
				limit = { species = { has_trait = trait_xenomorph } }
			}
			count_owned_pop_amount = {
				count >= 5000
				limit = { species = { has_trait = trait_xenomorph } }
			}
		}
		NOT = {
			any_owned_pop_group = {
				pop_group_size > 0
				species = {
					is_robotic = no
					NOT = { has_trait = trait_mechanical }
					NOT = { has_trait = trait_xenomorph }
				}
			}
		}
	}

	immediate = {
		set_carrier_flag = xit_xenomorph_terminal_collapse_started
		set_carrier_flag = xit_xenomorph_colony_overrun
		remove_modifier = xit_xenomorph_infestation
		remove_modifier = xit_xenomorph_outbreak
		remove_modifier = xit_xenomorph_overrun
		add_modifier = { modifier = xit_xenomorph_terminal_collapse days = -1 }
		add_planet_devastation = 100
	}

	option = {
		name = xit_infection.6.a
		hidden_effect = {
			xit_abandon_terminal_xenomorph_world = yes
		}
	}
}

planet_event = {
	id = xit_infection.9
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		NOT = { has_carrier_flag = xit_xenomorph_terminal_warning }
		NOT = { has_carrier_flag = xit_xenomorph_terminal_collapse_started }
		any_owned_pop_group = {
			species = { has_trait = trait_xenomorph }
		}
		OR = {
			pop_amount_percentage = {
				percentage >= 0.50
				limit = { species = { has_trait = trait_xenomorph } }
			}
			count_owned_pop_amount = {
				count >= 5000
				limit = { species = { has_trait = trait_xenomorph } }
			}
		}
		NOT = {
			any_owned_pop_group = {
				pop_group_size > 0
				species = {
					is_robotic = no
					NOT = { has_trait = trait_mechanical }
					NOT = { has_trait = trait_xenomorph }
				}
			}
		}
	}

	immediate = {
		set_timed_carrier_flag = { flag = xit_xenomorph_terminal_warning days = 1800 }
		set_carrier_flag = xit_xenomorph_colony_overrun
		remove_modifier = xit_xenomorph_infestation
		remove_modifier = xit_xenomorph_outbreak
		add_modifier = { modifier = xit_xenomorph_overrun days = -1 }
		add_planet_devastation = 20
		if = {
			limit = { owner = { is_ai = no } }
			planet_event = { id = xit_infection.11 }
		}
		planet_event = { id = xit_infection.10 days = 1800 }
	}
}

planet_event = {
	id = xit_infection.10
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		has_carrier_flag = xit_xenomorph_terminal_warning
		NOT = { has_carrier_flag = xit_xenomorph_terminal_collapse_started }
		any_owned_pop_group = {
			species = { has_trait = trait_xenomorph }
		}
		OR = {
			pop_amount_percentage = {
				percentage >= 0.50
				limit = { species = { has_trait = trait_xenomorph } }
			}
			count_owned_pop_amount = {
				count >= 5000
				limit = { species = { has_trait = trait_xenomorph } }
			}
		}
		NOT = {
			any_owned_pop_group = {
				pop_group_size > 0
				species = {
					is_robotic = no
					NOT = { has_trait = trait_mechanical }
					NOT = { has_trait = trait_xenomorph }
				}
			}
		}
	}

	immediate = {
		set_carrier_flag = xit_xenomorph_terminal_warning_mature
		planet_event = { id = xit_infection.6 }
	}
}

planet_event = {
	id = xit_infection.11
	title = xit_infection.11.name
	desc = xit_infection.11.desc
	picture = GFX_xit_event_terminal_xenomorph_collapse
	show_sound = xit_event_default
	location = ROOT

	is_triggered_only = yes

	option = {
		name = xit_infection.11.a
	}
}

planet_event = {
	id = xit_infection.12
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		has_modifier = xit_emergency_brood_suppression
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		any_owned_pop_group = {
			pop_group_size >= 100
			species = { has_trait = trait_xenomorph }
		}
	}

	immediate = {
		xit_suppress_one_xenomorph_pop = yes
	}
}

planet_event = {
	id = xit_infection.13
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = {
			is_country_type = default
			NOT = { xit_is_xenomorph_safe_owner = yes }
			OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish }
		}
		NOT = { has_carrier_flag = xit_emergency_brood_suppression_cooldown }
		OR = {
			has_modifier = xit_xenomorph_outbreak
			has_modifier = xit_xenomorph_overrun
			has_modifier = xit_xenomorph_terminal_collapse
			has_carrier_flag = xit_xenomorph_terminal_warning
		}
		any_owned_pop_group = {
			pop_group_size >= 100
			species = { has_trait = trait_xenomorph }
		}
	}

	immediate = {
		add_modifier = { modifier = xit_emergency_brood_suppression days = 1800 }
		set_timed_carrier_flag = { flag = xit_emergency_brood_suppression_cooldown days = 3600 }

		if = {
			limit = { has_modifier = xit_xenomorph_terminal_collapse }
			remove_modifier = xit_xenomorph_terminal_collapse
			add_modifier = { modifier = xit_xenomorph_overrun days = -1 }
			remove_carrier_flag = xit_xenomorph_terminal_collapse_started
		}
		if = {
			limit = { has_carrier_flag = xit_xenomorph_terminal_warning }
			remove_carrier_flag = xit_xenomorph_terminal_warning
			remove_carrier_flag = xit_xenomorph_terminal_warning_mature
			remove_modifier = xit_xenomorph_overrun
			add_modifier = { modifier = xit_xenomorph_outbreak days = 720 }
		}
		if = {
			limit = { owner = { is_ai = no } }
			planet_event = { id = xit_infection.14 }
		}
	}
}

planet_event = {
	id = xit_infection.14
	title = xit_infection.14.name
	desc = xit_infection.14.desc
	picture = GFX_xit_event_xenomorph_containment_breach
	show_sound = xit_event_default
	location = ROOT

	is_triggered_only = yes

	option = {
		name = xit_infection.14.a
	}
}

planet_event = {
	id = xit_infection.7
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		has_ground_combat = no
		has_modifier = xit_xenomorph_terminal_collapse
		has_carrier_flag = xit_xenomorph_outbreak_owner_assigned
		NOT = { has_carrier_flag = xit_xenomorph_terminal_world_transferred }
		any_owned_pop_group = {
			species = { has_trait = trait_xenomorph }
		}
		OR = {
			pop_amount_percentage = {
				percentage >= 0.50
				limit = { species = { has_trait = trait_xenomorph } }
			}
			count_owned_pop_amount = {
				count >= 5000
				limit = { species = { has_trait = trait_xenomorph } }
			}
		}
	}

	immediate = {
		xit_abandon_terminal_xenomorph_world = yes
	}
}

planet_event = {
	id = xit_infection.8
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = {
			is_country_type = default
			NOT = { xit_is_xenomorph_safe_owner = yes }
		}
		has_modifier = xit_xenomorph_terminal_collapse
		NOT = {
			OR = {
				pop_amount_percentage = {
					percentage >= 0.50
					limit = { species = { has_trait = trait_xenomorph } }
				}
				count_owned_pop_amount = {
					count >= 5000
					limit = { species = { has_trait = trait_xenomorph } }
				}
			}
		}
	}

	immediate = {
		remove_modifier = xit_xenomorph_terminal_collapse
		remove_modifier = xit_xenomorph_overrun
		remove_carrier_flag = xit_xenomorph_terminal_collapse_started
		remove_carrier_flag = xit_xenomorph_outbreak_owner_assigned
		remove_carrier_flag = xit_xenomorph_terminal_warning
		remove_carrier_flag = xit_xenomorph_terminal_warning_mature
		add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
	}
}

planet_event = {
	id = xit_infection.5
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { xit_is_xenomorph_safe_owner = yes }
		OR = {
			has_modifier = xit_xenomorph_infestation
			has_modifier = xit_xenomorph_outbreak
			has_modifier = xit_xenomorph_overrun
			has_modifier = xit_xenomorph_terminal_collapse
			has_deposit = d_xit_dormant_ovomorph_cluster
			any_owned_pop_group = {
				species = { has_trait = trait_xenomorph }
			}
		}
	}

	immediate = {
		remove_modifier = xit_xenomorph_infestation
		remove_modifier = xit_xenomorph_outbreak
		remove_modifier = xit_xenomorph_overrun
		remove_modifier = xit_xenomorph_terminal_collapse
		remove_carrier_flag = xit_xenomorph_outbreak_started
		remove_carrier_flag = xit_xenomorph_colony_overrun
		remove_carrier_flag = xit_xenomorph_terminal_collapse_started
		remove_carrier_flag = xit_xenomorph_terminal_warning
		remove_carrier_flag = xit_xenomorph_terminal_warning_mature
		add_modifier = { modifier = xit_managed_xenomorph_brood_world days = 720 }
	}
}

planet_event = {
	id = xit_infection.20
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colonizable = yes
		NOT = { has_planet_flag = xit_ovomorph_survey_checked }
		from = {
			is_country_type = default
			NOT = { xit_is_xenomorph_safe_owner = yes }
		}
	}

	immediate = {
		set_planet_flag = xit_ovomorph_survey_checked
		if = {
			limit = {
				OR = {
					has_deposit = d_xit_dormant_ovomorph_cluster
					has_modifier = xit_xenomorph_infestation
					has_modifier = xit_xenomorph_outbreak
					has_modifier = xit_xenomorph_overrun
					any_owned_pop_group = {
						species = { has_trait = trait_xenomorph }
					}
				}
			}
			set_planet_flag = xit_ovomorph_surveyed
			from = { set_country_flag = xit_ovomorph_survey_first_found }
			if = {
				limit = { exists = fromfrom.leader }
				random_list = {
					20 = { fromfrom = { fleet_event = { id = xit_infection.22 } } }
					80 = { from = { country_event = { id = xit_infection.21 } } }
				}
			}
			else = {
				from = { country_event = { id = xit_infection.21 } }
			}
		}
		else = {
			if = {
				limit = {
					years_passed >= 20
					from = {
						NOT = { has_country_flag = xit_ovomorph_survey_first_found }
					}
				}
				set_planet_flag = xit_ovomorph_surveyed
				from = { set_country_flag = xit_ovomorph_survey_first_found }
				if = {
					limit = { exists = fromfrom.leader }
					random_list = {
						25 = { fromfrom = { fleet_event = { id = xit_infection.22 } } }
						75 = { from = { country_event = { id = xit_infection.21 } } }
					}
				}
				else = {
					from = { country_event = { id = xit_infection.21 } }
				}
			}
			else_if = {
				limit = {
					from = {
						NOT = { has_country_flag = xit_ovomorph_survey_first_found }
						NOT = { has_country_flag = xit_ovomorph_survey_first_roll_started }
					}
				}
				random_list = {
					40 = {
						set_planet_flag = xit_ovomorph_surveyed
						from = {
							set_country_flag = xit_ovomorph_survey_first_found
							set_country_flag = xit_ovomorph_survey_first_roll_started
							set_timed_country_flag = { flag = xit_ovomorph_survey_first_window days = 7200 }
						}
						if = {
							limit = { exists = fromfrom.leader }
							random_list = {
								25 = { fromfrom = { fleet_event = { id = xit_infection.22 } } }
								75 = { from = { country_event = { id = xit_infection.21 } } }
							}
						}
						else = {
							from = { country_event = { id = xit_infection.21 } }
						}
					}
					60 = {
						from = {
							set_country_flag = xit_ovomorph_survey_first_roll_started
							set_timed_country_flag = { flag = xit_ovomorph_survey_first_window days = 7200 }
						}
					}
				}
			}
			else_if = {
				limit = {
					from = {
						has_country_flag = xit_ovomorph_survey_first_roll_started
						NOT = { has_country_flag = xit_ovomorph_survey_first_window }
						NOT = { has_country_flag = xit_ovomorph_survey_first_found }
					}
				}
				set_planet_flag = xit_ovomorph_surveyed
				from = { set_country_flag = xit_ovomorph_survey_first_found }
				if = {
					limit = { exists = fromfrom.leader }
					random_list = {
						25 = { fromfrom = { fleet_event = { id = xit_infection.22 } } }
						75 = { from = { country_event = { id = xit_infection.21 } } }
					}
				}
				else = {
					from = { country_event = { id = xit_infection.21 } }
				}
			}
			else = {
				random_list = {
					5 = {
						set_planet_flag = xit_ovomorph_surveyed
						from = { set_country_flag = xit_ovomorph_survey_first_found }
						if = {
							limit = { exists = fromfrom.leader }
							random_list = {
								25 = { fromfrom = { fleet_event = { id = xit_infection.22 } } }
								75 = { from = { country_event = { id = xit_infection.21 } } }
							}
						}
						else = {
							from = { country_event = { id = xit_infection.21 } }
						}
					}
					95 = {
					}
				}
			}
		}
	}
}

country_event = {
	id = xit_infection.21
	title = xit_infection.21.name
	desc = xit_infection.21.desc
	picture = GFX_xit_event_dormant_ovomorph_signatures
	location = FROM

	is_triggered_only = yes

	option = {
		name = xit_infection.21.a
		custom_tooltip = xit_infection.21.a.tooltip
		ai_chance = {
			factor = 65
		}
		hidden_effect = {
			if = {
				limit = {
					is_country_type = default
					NOT = { has_technology = tech_xit_xenomorph_biosecurity }
				}
				add_research_option = tech_xit_xenomorph_biosecurity
			}
			add_resource = {
				society_research = 300
			}
			from = {
				if = {
					limit = {
						is_colonizable = yes
						NOT = { has_deposit = d_xit_dormant_ovomorph_cluster }
					}
					add_deposit = d_xit_dormant_ovomorph_cluster
				}
				if = {
					limit = {
						is_colonizable = yes
						NOT = { exists = archaeological_site }
					}
					random_list = {
						40 = {
							create_archaeological_site = xit_subsurface_ovomorph_cache
						}
						60 = {
						}
					}
				}
				if = {
					limit = { root = { has_technology = tech_xit_ovomorph_dormancy_studies } }
					if = {
						limit = { root = { OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish } } }
						random_list = {
							2 = {
								add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
								xit_create_hidden_xenomorph_seed_pop = yes
							}
							98 = {
							}
						}
					}
					else_if = {
						limit = { root = { OR = { has_tradition = tr_xit_biosecurity_planetary_screening has_tradition = tr_xit_containment_planetary_screening } } }
						random_list = {
							5 = {
								add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
								xit_create_hidden_xenomorph_seed_pop = yes
							}
							95 = {
							}
						}
					}
					else_if = {
						limit = { root = { OR = { has_tradition = tr_xit_biosecurity_adopt has_tradition = tr_xit_containment_command_adopt } } }
						random_list = {
							10 = {
								add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
								xit_create_hidden_xenomorph_seed_pop = yes
							}
							90 = {
							}
						}
					}
					else = {
						random_list = {
							18 = {
								add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
								xit_create_hidden_xenomorph_seed_pop = yes
							}
							82 = {
							}
						}
					}
				}
				else_if = {
					limit = { root = { OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish } } }
					random_list = {
						5 = {
							add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
							xit_create_hidden_xenomorph_seed_pop = yes
						}
						95 = {
						}
					}
				}
				else_if = {
					limit = { root = { OR = { has_tradition = tr_xit_biosecurity_planetary_screening has_tradition = tr_xit_containment_planetary_screening } } }
					random_list = {
						12 = {
							add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
							xit_create_hidden_xenomorph_seed_pop = yes
						}
						88 = {
						}
					}
				}
				else_if = {
					limit = { root = { OR = { has_tradition = tr_xit_biosecurity_adopt has_tradition = tr_xit_containment_command_adopt } } }
					random_list = {
						20 = {
							add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
							xit_create_hidden_xenomorph_seed_pop = yes
						}
						80 = {
						}
					}
				}
				else = {
					random_list = {
						35 = {
							add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
							xit_create_hidden_xenomorph_seed_pop = yes
						}
						65 = {
						}
					}
				}
			}
			if = {
				limit = {
					is_ai = yes
					any_owned_planet = {
						is_colony = yes
						exists = owner
						NOT = { owner = { xit_is_xenomorph_safe_owner = yes } }
						NOT = {
							any_owned_pop_group = {
								species = { has_trait = trait_xenomorph }
							}
						}
						any_owned_pop_group = {
							pop_group_size >= 100
							species = {
								is_robotic = no
								NOT = { has_trait = trait_mechanical }
								NOT = { has_trait = trait_xenomorph }
							}
						}
					}
				}
				random_list = {
					60 = {
						random_owned_planet = {
							limit = {
								is_colony = yes
								exists = owner
								NOT = { owner = { xit_is_xenomorph_safe_owner = yes } }
								NOT = {
									any_owned_pop_group = {
										species = { has_trait = trait_xenomorph }
									}
								}
								any_owned_pop_group = {
									pop_group_size >= 100
									species = {
										is_robotic = no
										NOT = { has_trait = trait_mechanical }
										NOT = { has_trait = trait_xenomorph }
									}
								}
							}
							xit_hatch_dormant_ovomorph_cluster = yes
						}
					}
					40 = {
					}
				}
			}
		}
	}

	option = {
		name = xit_infection.21.b
		custom_tooltip = xit_infection.21.b.tooltip
		ai_chance = {
			factor = 20
		}
		add_resource = {
			engineering_research = 250
			unity = 100
		}
		from = {
			if = {
				limit = {
					has_deposit = d_xit_dormant_ovomorph_cluster
				}
				remove_deposit = d_xit_dormant_ovomorph_cluster
			}
		}
	}

	option = {
		name = xit_infection.21.c
		custom_tooltip = xit_infection.21.c.tooltip
		ai_chance = {
			factor = 15
		}
		add_resource = {
			unity = 150
		}
		from = {
			if = {
				limit = {
					is_colonizable = yes
					NOT = { has_deposit = d_xit_dormant_ovomorph_cluster }
				}
				add_deposit = d_xit_dormant_ovomorph_cluster
				add_modifier = { modifier = xit_ovomorph_quarantine_zone days = -1 }
			}
			if = {
				limit = {
					is_colonizable = yes
					NOT = { exists = archaeological_site }
				}
				random_list = {
					35 = {
						create_archaeological_site = xit_fossilized_brood_nursery
					}
					65 = {
					}
				}
			}
		}
	}
}

fleet_event = {
	id = xit_infection.22
	title = xit_infection.22.name
	desc = xit_infection.22.desc
	picture = GFX_xit_event_survey_team_lost
	location = FROM

	is_triggered_only = yes

	immediate = {
		if = {
			limit = { exists = leader }
			leader = { kill_leader = { show_notification = yes } }
		}
	}

	option = {
		name = xit_infection.22.a
		ai_chance = {
			factor = 70
		}
		owner = {
			if = {
				limit = {
					is_country_type = default
					NOT = { has_technology = tech_xit_xenomorph_biosecurity }
				}
				add_research_option = tech_xit_xenomorph_biosecurity
			}
			add_resource = {
				society_research = 600
				engineering_research = 250
			}
		}
		hidden_effect = {
			from = {
				if = {
					limit = { root = { owner = { has_technology = tech_xit_ovomorph_dormancy_studies } } }
					if = {
						limit = { root = { owner = { OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish } } } }
						random_list = {
							2 = {
								add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
								if = {
									limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
									add_deposit = d_xit_dormant_ovomorph_cluster
								}
								xit_create_hidden_xenomorph_seed_pop = yes
							}
							98 = {
								if = {
									limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
									add_deposit = d_xit_dormant_ovomorph_cluster
								}
							}
						}
					}
					else_if = {
						limit = { root = { owner = { OR = { has_tradition = tr_xit_biosecurity_planetary_screening has_tradition = tr_xit_containment_planetary_screening } } } }
						random_list = {
							5 = {
								add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
								if = {
									limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
									add_deposit = d_xit_dormant_ovomorph_cluster
								}
								xit_create_hidden_xenomorph_seed_pop = yes
							}
							95 = {
								if = {
									limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
									add_deposit = d_xit_dormant_ovomorph_cluster
								}
							}
						}
					}
					else = {
						random_list = {
							12 = {
								add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
								if = {
									limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
									add_deposit = d_xit_dormant_ovomorph_cluster
								}
								xit_create_hidden_xenomorph_seed_pop = yes
							}
							88 = {
								if = {
									limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
									add_deposit = d_xit_dormant_ovomorph_cluster
								}
							}
						}
					}
				}
				else_if = {
					limit = { root = { owner = { OR = { has_tradition = tr_xit_biosecurity_finish has_tradition = tr_xit_containment_command_finish } } } }
					random_list = {
						5 = {
							add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
							if = {
								limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
								add_deposit = d_xit_dormant_ovomorph_cluster
							}
							xit_create_hidden_xenomorph_seed_pop = yes
						}
						95 = {
							if = {
								limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
								add_deposit = d_xit_dormant_ovomorph_cluster
							}
						}
					}
				}
				else_if = {
					limit = { root = { owner = { OR = { has_tradition = tr_xit_biosecurity_planetary_screening has_tradition = tr_xit_containment_planetary_screening } } } }
					random_list = {
						12 = {
							add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
							if = {
								limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
								add_deposit = d_xit_dormant_ovomorph_cluster
							}
							xit_create_hidden_xenomorph_seed_pop = yes
						}
						88 = {
							if = {
								limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
								add_deposit = d_xit_dormant_ovomorph_cluster
							}
						}
					}
				}
				else = {
					random_list = {
						30 = {
							add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
							if = {
								limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
								add_deposit = d_xit_dormant_ovomorph_cluster
							}
							xit_create_hidden_xenomorph_seed_pop = yes
						}
						70 = {
							if = {
								limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
								add_deposit = d_xit_dormant_ovomorph_cluster
							}
						}
					}
				}
			}
		}
	}

	option = {
		name = xit_infection.22.b
		ai_chance = {
			factor = 30
		}
		owner = {
			add_resource = {
				unity = 300
				society_research = 150
			}
		}
		from = {
			if = {
				limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
				add_deposit = d_xit_dormant_ovomorph_cluster
			}
			add_modifier = { modifier = xit_ovomorph_quarantine_zone days = -1 }
		}
	}
}

planet_event = {
	id = xit_infection.30
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		NOT = { has_planet_flag = xit_ovomorph_excavation_found }
		NOT = { has_deposit = d_xit_dormant_ovomorph_cluster }
		OR = {
			has_modifier = xit_xenomorph_infestation
			has_modifier = xit_xenomorph_outbreak
			has_modifier = xit_xenomorph_overrun
			any_owned_pop_group = {
				species = { has_trait = trait_xenomorph }
			}
		}
	}

	immediate = {
		if = {
			limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_planetary_screening has_tradition = tr_xit_containment_planetary_screening } } }
			random_list = {
				3 = { planet_event = { id = xit_infection.31 } }
				97 = {
				}
			}
		}
		else = {
			random_list = {
				8 = { planet_event = { id = xit_infection.31 } }
				92 = {
				}
			}
		}
	}
}

planet_event = {
	id = xit_infection.31
	title = xit_infection.31.name
	desc = xit_infection.31.desc
	picture = GFX_xit_event_subsurface_ovomorph_cache
	location = ROOT

	is_triggered_only = yes

	immediate = {
		set_planet_flag = xit_ovomorph_excavation_found
	}

	option = {
		name = xit_infection.31.a
		ai_chance = {
			factor = 60
		}
		add_deposit = d_xit_dormant_ovomorph_cluster
		owner = {
			if = {
				limit = {
					is_country_type = default
					NOT = { has_technology = tech_xit_xenomorph_biosecurity }
				}
				add_research_option = tech_xit_xenomorph_biosecurity
			}
			add_resource = {
				society_research = 300
			}
		}
	}

	option = {
		name = xit_infection.31.b
		ai_chance = {
			factor = 25
		}
		random_list = {
			75 = {
				owner = {
					add_resource = {
						engineering_research = 300
						energy = 500
					}
				}
			}
			25 = {
				add_deposit = d_xit_dormant_ovomorph_cluster
				add_modifier = { modifier = xit_containment_strain days = 720 }
				owner = {
					add_resource = {
						society_research = 100
					}
				}
			}
		}
	}

	option = {
		name = xit_infection.31.c
		ai_chance = {
			factor = 15
		}
		add_deposit = d_xit_dormant_ovomorph_cluster
		add_modifier = { modifier = xit_ovomorph_quarantine_zone days = -1 }
		owner = {
			add_resource = {
				unity = 250
			}
		}
	}
}

planet_event = {
	id = xit_infection.33
	title = xit_infection.33.name
	desc = xit_infection.33.desc
	picture = GFX_xit_event_ovomorph_cluster_cleared
	location = ROOT

	is_triggered_only = yes

	option = {
		name = xit_infection.33.a
		owner = {
			if = {
				limit = {
					is_country_type = default
					NOT = { has_technology = tech_xit_xenomorph_biosecurity }
				}
				add_research_option = tech_xit_xenomorph_biosecurity
			}
		}
		if = {
			limit = {
				owner = {
					has_technology = tech_xit_ovomorph_dormancy_studies
					OR = { has_tradition = tr_xit_biosecurity_rapid_purge_teams has_tradition = tr_xit_containment_rapid_purge_teams }
				}
			}
			random_list = {
				90 = {
					owner = {
						add_resource = {
							society_research = 350
						}
					}
				}
				9 = {
					add_modifier = { modifier = xit_containment_strain days = 720 }
				}
				1 = {
					add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
					add_deposit = d_xit_dormant_ovomorph_cluster
					xit_create_hidden_xenomorph_seed_pop = yes
				}
			}
		}
		else_if = {
			limit = { owner = { has_technology = tech_xit_ovomorph_dormancy_studies } }
			random_list = {
				80 = {
					owner = {
						add_resource = {
							society_research = 350
						}
					}
				}
				15 = {
					add_modifier = { modifier = xit_containment_strain days = 720 }
				}
				5 = {
					add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
					add_deposit = d_xit_dormant_ovomorph_cluster
					xit_create_hidden_xenomorph_seed_pop = yes
				}
			}
		}
		else_if = {
			limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_rapid_purge_teams has_tradition = tr_xit_containment_rapid_purge_teams } } }
			random_list = {
				85 = {
					owner = {
						add_resource = {
							society_research = 350
						}
					}
				}
				12 = {
					add_modifier = { modifier = xit_containment_strain days = 720 }
				}
				3 = {
					add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
					add_deposit = d_xit_dormant_ovomorph_cluster
					xit_create_hidden_xenomorph_seed_pop = yes
				}
			}
		}
		else = {
			random_list = {
				70 = {
					owner = {
						add_resource = {
							society_research = 350
						}
					}
				}
				20 = {
					add_modifier = { modifier = xit_containment_strain days = 720 }
				}
				10 = {
					add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
					add_deposit = d_xit_dormant_ovomorph_cluster
					xit_create_hidden_xenomorph_seed_pop = yes
				}
			}
		}
	}
}

planet_event = {
	id = xit_infection.40
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		has_building = building_xit_xenomorph_containment_lab
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		NOT = { has_carrier_flag = xit_xenomorph_outbreak_started }
		any_owned_pop_group = {
			species = { has_trait = trait_xenomorph }
		}
	}

	immediate = {
		random_list = {
			4 = { planet_event = { id = xit_infection.41 } }
			96 = {
			}
		}
	}
}

planet_event = {
	id = xit_infection.41
	title = xit_infection.41.name
	desc = xit_infection.41.desc
	picture = GFX_xit_event_containment_lab_breach
	location = ROOT

	is_triggered_only = yes

	immediate = {
		add_modifier = { modifier = xit_containment_strain days = 1080 }
		remove_modifier = xit_xenomorph_outbreak
		remove_modifier = xit_xenomorph_overrun
		add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
		add_planet_devastation = 10
	}

	option = {
		name = xit_infection.41.a
	}
}

planet_event = {
	id = xit_infection.50
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		has_building = building_xenomorph_ovomorph_chamber
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
	}

	immediate = {
		remove_building = building_xenomorph_ovomorph_chamber
		if = {
			limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
			add_deposit = d_xit_dormant_ovomorph_cluster
		}
		add_modifier = { modifier = xit_containment_strain days = 720 }
	}
}

planet_event = {
	id = xit_infection.70
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		has_deposit = d_xit_dormant_ovomorph_cluster
		owner = {
			is_country_type = default
			NOT = { xit_is_xenomorph_safe_owner = yes }
		}
		NOT = {
			any_owned_pop_group = {
				species = { has_trait = trait_xenomorph }
			}
		}
		any_owned_pop_group = {
			pop_group_size >= 100
			species = {
				is_robotic = no
				NOT = { has_trait = trait_mechanical }
				NOT = { has_trait = trait_xenomorph }
			}
		}
	}

	immediate = {
		if = {
			limit = { owner = { is_ai = yes } }
			if = {
				limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_planetary_screening has_tradition = tr_xit_containment_planetary_screening } } }
				random_list = {
					8 = { xit_hatch_dormant_ovomorph_cluster = yes }
					92 = {
					}
				}
			}
			else_if = {
				limit = { owner = { has_ascension_perk = ap_xit_xenomorph_research_protocols } }
				random_list = {
					12 = { xit_hatch_dormant_ovomorph_cluster = yes }
					88 = {
					}
				}
			}
			else_if = {
				limit = { has_building = building_xit_xenomorph_containment_lab }
				random_list = {
					12 = { xit_hatch_dormant_ovomorph_cluster = yes }
					88 = {
					}
				}
			}
			else_if = {
				limit = { owner = { has_technology = tech_xit_xenomorph_biosecurity } }
				random_list = {
					22 = { xit_hatch_dormant_ovomorph_cluster = yes }
					78 = {
					}
				}
			}
			else = {
				random_list = {
					35 = { xit_hatch_dormant_ovomorph_cluster = yes }
					65 = {
					}
				}
			}
		}
		else = {
			if = {
				limit = { owner = { OR = { has_tradition = tr_xit_biosecurity_planetary_screening has_tradition = tr_xit_containment_planetary_screening } } }
				random_list = {
					1 = { xit_hatch_dormant_ovomorph_cluster = yes }
					99 = {
					}
				}
			}
			else_if = {
				limit = { owner = { has_ascension_perk = ap_xit_xenomorph_research_protocols } }
				random_list = {
					2 = { xit_hatch_dormant_ovomorph_cluster = yes }
					98 = {
					}
				}
			}
			else_if = {
				limit = { has_building = building_xit_xenomorph_containment_lab }
				random_list = {
					2 = { xit_hatch_dormant_ovomorph_cluster = yes }
					98 = {
					}
				}
			}
			else_if = {
				limit = { owner = { has_technology = tech_xit_xenomorph_biosecurity } }
				random_list = {
					3 = { xit_hatch_dormant_ovomorph_cluster = yes }
					97 = {
					}
				}
			}
			else = {
				random_list = {
					5 = { xit_hatch_dormant_ovomorph_cluster = yes }
					95 = {
					}
				}
			}
		}
	}
}

planet_event = {
	id = xit_infection.80
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		from = {
			is_country_type = default
			xit_is_xenomorph_safe_owner = yes
		}
		NOT = { has_carrier_flag = xit_recent_xenomorph_ground_seed }
		any_owned_pop_group = {
			pop_group_size >= 100
			species = {
				is_robotic = no
				NOT = { has_trait = trait_mechanical }
				NOT = { has_trait = trait_xenomorph }
			}
		}
	}

	immediate = {
		set_timed_carrier_flag = { flag = xit_recent_xenomorph_ground_seed days = 720 }
		if = {
			limit = { from = { has_ascension_perk = ap_xenomorph_apex_autogenic_brood } }
			set_timed_carrier_flag = { flag = xit_perfect_host_cycle_ground_assault days = 5 }
		}
		xit_apply_xenomorph_assault_exposure = yes
	}
}

planet_event = {
	id = xit_infection.81
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = { NOT = { xit_is_xenomorph_safe_owner = yes } }
		from = {
			is_country_type = default
			xit_is_xenomorph_safe_owner = yes
		}
		NOT = { has_carrier_flag = xit_recent_xenomorph_bombardment_seed }
		any_owned_pop_group = {
			pop_group_size >= 100
			species = {
				is_robotic = no
				NOT = { has_trait = trait_mechanical }
				NOT = { has_trait = trait_xenomorph }
			}
		}
	}

	immediate = {
		set_timed_carrier_flag = { flag = xit_recent_xenomorph_bombardment_seed days = 720 }
		if = {
			limit = { from = { has_ascension_perk = ap_xenomorph_apex_autogenic_brood } }
			set_timed_carrier_flag = { flag = xit_perfect_host_cycle_bombardment days = 5 }
		}
		xit_apply_xenomorph_assault_exposure = yes
	}
}

planet_event = {
	id = xit_infection.84
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		owner = {
			is_country_type = default
			OR = { has_tradition = tr_xit_biosecurity_sterile_logistics has_tradition = tr_xit_containment_orbital_cordon }
		}
		NOT = { has_modifier = xit_orbital_cordon_lockdown }
	}

	immediate = {
		add_modifier = { modifier = xit_orbital_cordon_lockdown days = 180 }
	}
}

country_event = {
	id = xit_infection.60
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_country_type = default
		NOT = { has_country_flag = xit_recent_xenomorph_bio_wreckage }
		NOT = { xit_is_xenomorph_safe_owner = yes }
		exists = from
		from = {
			is_country_type = default
			xit_is_xenomorph_safe_owner = yes
		}
		exists = fromfrom
		fromfrom = { exists = solar_system }
	}

	immediate = {
		set_timed_country_flag = { flag = xit_recent_xenomorph_bio_wreckage days = 360 }
		fromfrom.solar_system = {
			create_ambient_object = {
				type = "small_debris_object"
				location = this
			}
			last_created_ambient_object = {
				set_ambient_object_flag = xit_xenomorph_bio_wreckage
				enable_special_project = {
					name = "XIT_XENOMORPH_BIO_WRECKAGE_PROJECT"
					location = this
					owner = root
				}
			}
		}
	}
}

starbase_event = {
	id = xit_infection.61
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		exists = owner
		owner = { xit_is_xenomorph_safe_owner = yes }
		exists = from
		from = {
			exists = owner
			owner = {
				is_country_type = default
				NOT = { has_country_flag = xit_recent_xenomorph_bio_wreckage }
				NOT = { xit_is_xenomorph_safe_owner = yes }
			}
		}
		exists = solar_system
	}

	immediate = {
		from = {
			owner = {
				save_event_target_as = xit_wreckage_project_owner
				set_timed_country_flag = { flag = xit_recent_xenomorph_bio_wreckage days = 360 }
			}
		}
		solar_system = {
			create_ambient_object = {
				type = "small_debris_object"
				location = this
			}
			last_created_ambient_object = {
				set_ambient_object_flag = xit_xenomorph_bio_wreckage
				enable_special_project = {
					name = "XIT_XENOMORPH_BIO_WRECKAGE_PROJECT"
					location = this
					owner = event_target:xit_wreckage_project_owner
				}
			}
		}
	}
}

ship_event = {
	id = xit_infection.63
	title = xit_infection.63.name
	desc = xit_infection.63.desc
	picture = GFX_xit_event_xenomorph_bio_wreckage_analyzed
	location = FROM

	is_triggered_only = yes

	option = {
		name = xit_infection.63.a
		owner = {
			random_list = {
				50 = {
					add_resource = {
						engineering_research = 500
						society_research = 250
						alloys = 150
					}
				}
				35 = {
					if = {
						limit = {
							is_country_type = default
							NOT = { has_technology = tech_xit_xenomorph_biosecurity }
						}
						add_research_option = tech_xit_xenomorph_biosecurity
					}
					add_resource = {
						society_research = 600
						engineering_research = 200
					}
				}
				15 = {
					add_resource = {
						society_research = 250
						engineering_research = 250
					}
					if = {
						limit = {
							any_owned_planet = {
								is_colony = yes
							}
						}
						random_owned_planet = {
							limit = { is_colony = yes }
							add_modifier = { modifier = xit_xenomorph_infestation days = 720 }
							xit_create_hidden_xenomorph_seed_pop = yes
						}
					}
					else = {
						add_resource = {
							energy = 500
						}
					}
				}
			}
		}
		hidden_effect = {
			fromfrom = { destroy_ambient_object = this }
		}
	}
}

country_event = {
	id = xit_infection.90
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_country_type = default
		has_ascension_perk = ap_xenomorph_apex_autogenic_brood
		owner_species = { has_trait = trait_xenomorph }
		NOT = { has_country_flag = xit_perfect_host_cycle_recent_pulse }
	}

	immediate = {
		set_timed_country_flag = { flag = xit_perfect_host_cycle_recent_pulse days = 1800 }
		random_list = {
			40 = {
				random_owned_planet = {
					limit = { xit_can_receive_perfect_host_cycle_seed = yes }
					xit_apply_perfect_host_cycle_seed = yes
				}
			}
			35 = {
				random_galaxy_planet = {
					limit = {
						xit_can_receive_perfect_host_cycle_seed = yes
						OR = {
							has_carrier_flag = xit_recent_xenomorph_ground_seed
							has_carrier_flag = xit_recent_xenomorph_bombardment_seed
							has_modifier = xit_containment_strain
							has_modifier = xit_ovomorph_quarantine_zone
						}
					}
					xit_apply_perfect_host_cycle_seed = yes
				}
			}
			25 = {
				random_galaxy_planet = {
					limit = { xit_can_receive_perfect_host_cycle_seed = yes }
					xit_apply_perfect_host_cycle_seed = yes
				}
			}
		}
	}
}

country_event = {
	id = xit_infection.92
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		is_country_type = default
		has_ascension_perk = ap_xenomorph_apex_autogenic_brood
		owner_species = { has_trait = trait_xenomorph }
	}

	immediate = {
		remove_modifier = xit_perfect_host_cycle_food_adaptation_500
		remove_modifier = xit_perfect_host_cycle_food_adaptation_1000
		remove_modifier = xit_perfect_host_cycle_food_adaptation_1500
		remove_modifier = xit_perfect_host_cycle_food_adaptation_2000

		if = {
			limit = { has_monthly_income = { resource = food value >= 2000 } }
			add_modifier = { modifier = xit_perfect_host_cycle_food_adaptation_2000 days = 400 }
		}
		else_if = {
			limit = { has_monthly_income = { resource = food value >= 1500 } }
			add_modifier = { modifier = xit_perfect_host_cycle_food_adaptation_1500 days = 400 }
		}
		else_if = {
			limit = { has_monthly_income = { resource = food value >= 1000 } }
			add_modifier = { modifier = xit_perfect_host_cycle_food_adaptation_1000 days = 400 }
		}
		else_if = {
			limit = { has_monthly_income = { resource = food value >= 500 } }
			add_modifier = { modifier = xit_perfect_host_cycle_food_adaptation_500 days = 400 }
		}
	}
}

planet_event = {
	id = xit_infection.91
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		xit_can_receive_perfect_host_cycle_seed = yes
	}

	immediate = {
		xit_apply_perfect_host_cycle_seed = yes
	}
}

country_event = {
	id = xit_infection.82
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_owned_planet = {
			is_colony = yes
			has_ground_combat = no
			has_modifier = xit_xenomorph_terminal_collapse
			has_carrier_flag = xit_xenomorph_outbreak_owner_assigned
			NOT = { has_carrier_flag = xit_xenomorph_terminal_world_transferred }
			any_owned_pop_group = {
				species = { has_trait = trait_xenomorph }
			}
			NOT = {
				any_owned_pop_group = {
					pop_group_size > 0
					species = {
						is_robotic = no
						NOT = { has_trait = trait_mechanical }
						NOT = { has_trait = trait_xenomorph }
					}
				}
			}
		}
	}

	immediate = {
		every_owned_planet = {
			limit = {
				is_colony = yes
				has_ground_combat = no
				has_modifier = xit_xenomorph_terminal_collapse
				has_carrier_flag = xit_xenomorph_outbreak_owner_assigned
				NOT = { has_carrier_flag = xit_xenomorph_terminal_world_transferred }
				any_owned_pop_group = {
					species = { has_trait = trait_xenomorph }
				}
				NOT = {
					any_owned_pop_group = {
						pop_group_size > 0
						species = {
							is_robotic = no
							NOT = { has_trait = trait_mechanical }
							NOT = { has_trait = trait_xenomorph }
						}
					}
				}
			}
			xit_abandon_terminal_xenomorph_world = yes
		}
	}
}

planet_event = {
	id = xit_infection.83
	title = xit_infection.83.name
	desc = xit_infection.83.desc
	picture = GFX_xit_event_dormant_ovomorph_signatures
	show_sound = xit_event_default
	location = ROOT
	is_triggered_only = yes

	trigger = {
		is_colony = yes
		exists = owner
		has_carrier_flag = xit_abandoned_xenomorph_world
		has_deposit = d_xit_dormant_ovomorph_cluster
		NOT = { has_carrier_flag = xit_abandoned_xenomorph_world_reactivated }
	}

	immediate = {
		set_carrier_flag = xit_abandoned_xenomorph_world_reactivated
		if = {
			limit = { owner = { xit_is_xenomorph_safe_owner = yes } }
			add_modifier = { modifier = xit_managed_xenomorph_brood_world days = -1 }
		}
		else = {
			add_modifier = { modifier = xit_ovomorph_quarantine_zone days = -1 }
			random_list = {
				60 = {
					add_modifier = { modifier = xit_containment_strain days = 720 }
				}
				40 = {
					xit_hatch_dormant_ovomorph_cluster = yes
				}
			}
		}
	}

	option = {
		name = xit_infection.83.a
	}
}

country_event = {
	id = xit_infection.100
	title = xit_infection.100.name
	desc = xit_infection.100.desc
	picture = GFX_xit_event_dormant_ovomorph_signatures
	show_sound = xit_galactic_infestation_quiet
	is_triggered_only = yes

	trigger = {
		is_ai = no
		OR = {
			is_xenomorph_empire = yes
		}
		NOT = { has_country_flag = xit_galactic_infestation_notice_seen }
	}

	immediate = {
		set_country_flag = xit_galactic_infestation_notice_seen
	}

	option = {
		name = xit_infection.100.a
	}
}

country_event = {
	id = xit_infection.101
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		OR = {
			is_xenomorph_empire = yes
		}
		NOT = { has_country_flag = xit_galactic_infestation_recent_seed }
	}

	immediate = {
		set_timed_country_flag = { flag = xit_galactic_infestation_recent_seed days = 1800 }
		if = {
			limit = {
				any_country = {
					is_country_type = default
					NOT = { is_same_value = root }
					NOT = { xit_is_xenomorph_safe_owner = yes }
					has_established_contact = root
					is_rival = root
					any_owned_planet = {
						is_colony = yes
						is_capital = no
						NOT = { has_deposit = d_xit_dormant_ovomorph_cluster }
						NOT = { has_modifier = xit_xenomorph_infestation }
					}
				}
			}
			random_country = {
				limit = {
					is_country_type = default
					NOT = { is_same_value = root }
					NOT = { xit_is_xenomorph_safe_owner = yes }
					has_established_contact = root
					is_rival = root
					any_owned_planet = {
						is_colony = yes
						is_capital = no
						NOT = { has_deposit = d_xit_dormant_ovomorph_cluster }
						NOT = { has_modifier = xit_xenomorph_infestation }
					}
				}
				random_owned_planet = {
					limit = {
						is_colony = yes
						is_capital = no
						NOT = { has_deposit = d_xit_dormant_ovomorph_cluster }
						NOT = { has_modifier = xit_xenomorph_infestation }
					}
					xit_galactic_infestation_seed_target = yes
					root = {
						if = {
							limit = { is_ai = no }
							country_event = { id = xit_infection.102 }
						}
					}
				}
			}
		}
		else_if = {
			limit = {
				any_country = {
					is_country_type = default
					NOT = { is_same_value = root }
					NOT = { xit_is_xenomorph_safe_owner = yes }
					has_established_contact = root
					any_owned_planet = {
						is_colony = yes
						is_capital = no
						NOT = { has_deposit = d_xit_dormant_ovomorph_cluster }
						NOT = { has_modifier = xit_xenomorph_infestation }
					}
				}
			}
			random_country = {
				limit = {
					is_country_type = default
					NOT = { is_same_value = root }
					NOT = { xit_is_xenomorph_safe_owner = yes }
					has_established_contact = root
					any_owned_planet = {
						is_colony = yes
						is_capital = no
						NOT = { has_deposit = d_xit_dormant_ovomorph_cluster }
						NOT = { has_modifier = xit_xenomorph_infestation }
					}
				}
				random_owned_planet = {
					limit = {
						is_colony = yes
						is_capital = no
						NOT = { has_deposit = d_xit_dormant_ovomorph_cluster }
						NOT = { has_modifier = xit_xenomorph_infestation }
					}
					xit_galactic_infestation_seed_target = yes
					root = {
						if = {
							limit = { is_ai = no }
							country_event = { id = xit_infection.102 }
						}
					}
				}
			}
		}
		else = {
			if = {
				limit = { is_ai = no }
				country_event = { id = xit_infection.103 }
			}
		}
	}
}

country_event = {
	id = xit_infection.102
	title = xit_infection.102.name
	desc = xit_infection.102.desc
	picture = GFX_xit_event_dormant_ovomorph_signatures
	show_sound = xit_galactic_infestation_quiet
	is_triggered_only = yes

	option = {
		name = xit_infection.102.a
	}
}

country_event = {
	id = xit_infection.103
	title = xit_infection.103.name
	desc = xit_infection.103.desc
	picture = GFX_xit_event_dormant_ovomorph_signatures
	show_sound = xit_galactic_infestation_quiet
	is_triggered_only = yes

	option = {
		name = xit_infection.103.a
	}
}

country_event = {
	id = xit_infection.119
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		NOT = { has_global_flag = xit_acheron_ovomorph_vault_spawned }
		any_galaxy_planet = {
			has_planet_flag = xit_acheron_ovomorph_vault_candidate
			NOT = { exists = archaeological_site }
		}
	}

	immediate = {
		random_galaxy_planet = {
			limit = {
				has_planet_flag = xit_acheron_ovomorph_vault_candidate
				NOT = { exists = archaeological_site }
			}
			create_archaeological_site = xit_acheron_ovomorph_vault
			set_planet_flag = xit_acheron_ovomorph_vault_created
		}
		set_global_flag = xit_acheron_ovomorph_vault_spawned
	}
}

fleet_event = {
	id = xit_infection.120
	title = xit_infection.120.name
	desc = xit_infection.120.desc
	picture = GFX_xit_event_subsurface_ovomorph_cache
	show_sound = xit_event_default
	location = from

	archaeology = yes
	is_triggered_only = yes

	option = {
		name = xit_infection.120.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = 4
				min = 150
				max = 350
			}
			if = {
				limit = {
					NOT = { has_technology = tech_xit_xenomorph_biosecurity }
					can_research_technology = tech_xit_xenomorph_biosecurity
					NOT = { has_tech_option = tech_xit_xenomorph_biosecurity }
				}
				add_research_option = tech_xit_xenomorph_biosecurity
			}
		}
	}
}

fleet_event = {
	id = xit_infection.121
	title = xit_infection.121.name
	desc = xit_infection.121.desc
	picture = GFX_xit_event_survey_team_lost
	show_sound = xit_event_default
	location = from

	archaeology = yes
	is_triggered_only = yes

	option = {
		name = xit_infection.121.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = 5
				min = 200
				max = 450
			}
		}
		if = {
			limit = { owner = { NOT = { xit_is_xenomorph_safe_owner = yes } } }
			random_list = {
				65 = {
					from.planet = {
						add_modifier = { modifier = xit_containment_strain days = 720 }
					}
				}
				35 = {
				}
			}
		}
		else = {
			owner = {
				add_resource = { food = 500 }
			}
		}
	}
}

fleet_event = {
	id = xit_infection.122
	title = xit_infection.122.name
	desc = xit_infection.122.desc
	picture = GFX_xit_event_ovomorph_cluster_cleared
	show_sound = xit_event_default
	location = from

	archaeology = yes
	is_triggered_only = yes

	option = {
		name = xit_infection.122.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = 6
				min = 250
				max = 600
			}
		}
		if = {
			limit = { owner = { xit_is_xenomorph_safe_owner = yes } }
			from.planet = {
				if = {
					limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
					add_deposit = d_xit_dormant_ovomorph_cluster
				}
				add_modifier = { modifier = xit_ovomorph_quarantine_zone days = -1 }
			}
			owner = { add_resource = { food = 1000 } }
		}
		else = {
			random_list = {
				50 = {
					from.planet = {
						if = {
							limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
							add_deposit = d_xit_dormant_ovomorph_cluster
						}
						add_modifier = { modifier = xit_containment_strain days = 1800 }
					}
				}
				35 = {
					from.planet = {
						xit_apply_xenomorph_exposure_seed = yes
					}
				}
				15 = {
					from.planet = {
						add_modifier = { modifier = xit_ovomorph_quarantine_zone days = -1 }
					}
				}
			}
		}
	}
}

fleet_event = {
	id = xit_infection.123
	title = xit_infection.123.name
	desc = xit_infection.123.desc
	picture = GFX_xit_event_subsurface_ovomorph_cache
	show_sound = xit_event_default
	location = from

	archaeology = yes
	is_triggered_only = yes

	option = {
		name = xit_infection.123.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = 4
				min = 150
				max = 350
			}
		}
		if = {
			limit = { owner = { NOT = { xit_is_xenomorph_safe_owner = yes } } }
			random_list = {
				30 = {
					from.planet = {
						add_modifier = { modifier = xit_containment_strain days = 720 }
					}
				}
				70 = {
				}
			}
		}
	}
}

fleet_event = {
	id = xit_infection.124
	title = xit_infection.124.name
	desc = xit_infection.124.desc
	picture = GFX_xit_event_ovomorph_cluster_cleared
	show_sound = xit_event_default
	location = from

	archaeology = yes
	is_triggered_only = yes

	option = {
		name = xit_infection.124.a
		owner = {
			if = {
				limit = {
					is_country_type = default
					NOT = { has_technology = tech_xit_xenomorph_biosecurity }
					can_research_technology = tech_xit_xenomorph_biosecurity
					NOT = { has_tech_option = tech_xit_xenomorph_biosecurity }
				}
				add_research_option = tech_xit_xenomorph_biosecurity
			}
			add_monthly_resource_mult = {
				resource = society_research
				value = 6
				min = 250
				max = 600
			}
		}
		if = {
			limit = { owner = { xit_is_xenomorph_safe_owner = yes } }
			owner = { add_resource = { food = 750 } }
			from.planet = {
				if = {
					limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
					add_deposit = d_xit_dormant_ovomorph_cluster
				}
			}
		}
		else = {
			random_list = {
				45 = {
					from.planet = {
						add_modifier = { modifier = xit_ovomorph_quarantine_zone days = -1 }
					}
				}
				35 = {
					from.planet = {
						add_modifier = { modifier = xit_containment_strain days = 1800 }
						if = {
							limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
							add_deposit = d_xit_dormant_ovomorph_cluster
						}
					}
				}
				20 = {
					from.planet = {
						xit_apply_xenomorph_exposure_seed = yes
					}
				}
			}
		}
	}
}

fleet_event = {
	id = xit_infection.125
	title = xit_infection.125.name
	desc = xit_infection.125.desc
	picture = GFX_xit_event_dormant_ovomorph_signatures
	show_sound = xit_event_default
	location = from

	archaeology = yes
	is_triggered_only = yes

	option = {
		name = xit_infection.125.a
		owner = {
			add_resource = {
				society_research = 250
				unity = 100
			}
		}
	}
}

fleet_event = {
	id = xit_infection.126
	title = xit_infection.126.name
	desc = xit_infection.126.desc
	picture = GFX_xit_event_survey_team_lost
	show_sound = xit_event_default
	location = from

	archaeology = yes
	is_triggered_only = yes

	option = {
		name = xit_infection.126.a
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = 5
				min = 200
				max = 500
			}
		}
		if = {
			limit = { owner = { xit_is_xenomorph_safe_owner = yes } }
			owner = { add_resource = { food = 1000 unity = 150 } }
		}
		else = {
			random_list = {
				40 = {
					from.planet = {
						add_modifier = { modifier = xit_containment_strain days = 1800 }
					}
				}
				30 = {
					from.planet = {
						if = {
							limit = { NOT = { has_deposit = d_xit_dormant_ovomorph_cluster } }
							add_deposit = d_xit_dormant_ovomorph_cluster
						}
						add_modifier = { modifier = xit_ovomorph_quarantine_zone days = -1 }
					}
				}
				30 = {
					from.planet = {
						xit_apply_xenomorph_exposure_seed = yes
					}
				}
			}
		}
	}
}

